<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/11/13
  Time: 19:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>查看所有用户</title>
    <style type="text/css" rel="stylesheet">
        body{
            font-family: "楷体";
            font-size: 16px;
        }
        .all{
            width: 900px;
            max-height: 550px;
            overflow: auto;
            border: 2px solid red;
            margin: 0 auto;
            padding: 50px 30px;
            box-sizing: border-box;
        }
        .yheader{
            font-size: 18px;
            font-weight: 600;
            color: red;
            margin-bottom: 10px;
        }
        table{
            width: 850px;
            margin: 0 auto;
        }
        td{
            text-align: center;
        }
        a{
            color: #a39933;
            text-decoration: none;
            font-family: "楷体";
            font-weight: 600;
        }
        a:hover{
            color: red;
        }
    </style>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
<article class="all">
    <div class="yheader">当前位置&nbsp;&gt;&gt;&nbsp;管理所有用户</div>
    <table border="1">
        <tr>
            <th>编号</th>
            <th>用户名</th>
            <th>出生日期</th>
            <th>联系方式</th>
            <th>邮箱地址</th>
            <th>注册时间</th>
            <th>用户类型</th>
            <th>管理</th>
        </tr>
        <c:forEach items="${requestScope.users}" var="user" varStatus="state">
            <tr>
                <td style="display: none" class="id">${user.userId}</td>
                <td>${state.count}</td>
                <td>${user.username}</td>
                <td>${user.userBirthday}</td>
                <td>${user.userTel}</td>
                <td>${user.userEmail}</td>
                <td>${user.userRegisterTime}</td>
                <td>${user.userRoleType==1?"VIP用户":"普通用户"}</td>
                <td><a href="javascript:void(0);" class="del">删除</a></td>
            </tr>
        </c:forEach>
    </table>
</article>
<script>
    $(document).ready(function () {
        $(".del").click(function () {
            if(confirm("该操作会导致用户无法使用，确定操作吗？")){
                var id = $(this).parent("td").siblings(".id").text();
                $.ajax({
                    url:"/SuperAdminServlet?type=delbyid",
                    data:"id="+id,
                    type:"get",
                    dataType:"text",
                    async:true,
                    success:function (data) {
                        if(data == "1"){
                            alert("删除成功！");
                            window.location.reload();
                        }else{
                            alert("该用户还有未完操作，删除失败！");
                        }
                    },
                    error:function (error) {
                        alert("操作失败！");

                    }
                })
            }else
            {
                return false;
            }
        })
    })
</script>
</body>
</html>
